package com.blog.admin.mapper;

import java.util.Set;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import com.blog.admin.pojo.auth.Role;
import com.github.pagehelper.Page;


@Component
public interface RoleMapper {
	@Select("SELECT r.role_name FROM user_role ur LEFT JOIN role r ON r.id = ur.role_id \n" + "LEFT JOIN user su ON ur.user_id = su.id WHERE su.id = #{userId}")
	Set<String> findRoleNameByUserId(@Param("userId") int userId);

	/**
	 * 分页查询将角色
	 * 
	 * @return
	 */
	Page<Role> getRoleList();

	/**
	 * 删除角色信息
	 */
	Integer deleteRole(Integer valueOf);

	/**
	 * 根据id获取角色信息
	 * @param id
	 * @return
	 */
	Role getRoleById(Integer id);

	/**
	 * 更新角色
	 * @param id
	 * @return
	 */
	void update(Role role);

	/**
	 * 保存角色
	 * @param role
	 * @return
	 */
	Integer save(Role role);
}